app.controller("recordCtrl",function($rootScope,$scope,httpService,$timeout,$localStorage,wtmapService){$scope.searchParams={},$scope.searchParams.label="提交时间",$scope.count=0,$scope.RecordType=wtSys.Emun.RecordType,//记录类型
$scope.searchList=[{typeName:"类型",typeList:[{Id:3,Name:"巡查反馈"},{Id:4,Name:"维修反馈"}],isRadio:!0}],/*==============设置选择设施位置信息 Begin=============================*/
$scope.mapheight=$(".rgt-wrap").height()-85||700,$scope.mapIntialed=function(scope){var promise=wtmapService.intialMap("map1",!1,0,$rootScope.arcgisConfig.lods);//同步调用，获取承诺接口
promise.then(function(mapobj){
//添加底图（本系统是cad发布的图层）
mapobj.addDynamicMap($rootScope.arcgisConfig.baseMap),
//默认中心点
mapobj.zoomTobyXY(175307.451,135762.144,15),
//将mapobj对像暴露到作用域中
$scope.mapobj=mapobj},function(err){console.log(err)})},/**
     * 绘制记录点信息
     * @param mapobj 地图对像
     * @param recordPoints [points with isFinished]
     */
$scope.drawRecordPoint=function(mapobj,recordPoints){if(!mapobj)return void $timeout(function(){$scope.drawRecordPoint($scope.mapobj,recordPoints)},500);var DeviceDrawOption={layerid:"device",
//title : item.Name,
symbolUrl:"/assets/img/Icons/patron_巡查点32.png",symbolStyle:{height:32,width:32,angle:0,xOffset:0,yOffset:16}},FlagDrawOption={layerid:"flag",
//title : item.Name,
symbolUrl:"/assets/img/Icons/聚焦框64.png",symbolStyle:{width:34,height:34,angle:0,xOffset:0,yOffset:17}},points=[];
//0、清除原有的图层
mapobj.drawApi.clearGraphics("device"),mapobj.drawApi.clearGraphics("flag"),
//1、绘制任务点及完成
recordPoints.forEach(function(item,index){points.push([item.Lng,item.Lat]),mapobj.drawApi.drawPoint(item.Lng,item.Lat,DeviceDrawOption),item.IsFinish===!0&&mapobj.drawApi.drawPoint(item.Lng,item.Lat,FlagDrawOption)});
//2、获取定位中点
var centerPoint=mapobj.getCenterPoint(points);mapobj.zoomTobyXY(centerPoint.x,centerPoint.y,15)},/*==============设置选择设施位置信息 End=============================*/
// 初始化查询变量
$scope.initParam=function(){$scope.recordList=[],$scope.page=1,$scope.busy=!1,$scope.limit=10,$scope.isGetDetailTag=!0},
//获取工作记录列表
$scope.getRecordList=function(isSearch){if(isSearch&&$scope.initParam(),$scope.busy)return!1;var key=$scope.key?$scope.key:"",recordtype="";if($scope.searchModel){var arr=$scope.searchModel;if(arr.length>0){var recordtypeArr=[];arr.forEach(function(item,index){recordtypeArr.push(item.Id)}),recordtype=recordtypeArr.join(",")}}var begintime=$scope.searchParams.begintime;begintime=begintime?moment(begintime).format("YYYY-MM-DD"):"";var endtime=$scope.searchParams.endtime;endtime=endtime?moment(endtime).format("YYYY-MM-DD"):"";var path="/record?page="+$scope.page+"&limit="+$scope.limit+"&filter=key:"+key+";recordtype:"+recordtype+";begintime:"+begintime+";endtime:"+endtime;$scope.busy=!0,httpService.request("GET",path,null,function(result){if($scope.count=result.count,angular.forEach(result.data,function(data,i){$scope.recordList.push(data)}),result.data.length>=$scope.limit&&($scope.busy=!1,$scope.page+=1),$scope.recordList.length>0&&$scope.isGetDetailTag){$scope.isGetDetailTag=!1;var arr=$scope.recordList;$scope.activeId=arr[0].Id}})},
//获取工作记录详情
$scope.getRecordDetail=function(){var path="/record/"+$scope.activeId;httpService.request("GET",path,null,function(result){$scope.recordDetailModel=result.data,
// 被选中点的位置(设置默认值)
// console.log(result.data.Location);
$scope.drawRecordPoint($scope.mapobj,result.data.Location)})},
//获取右侧model
$scope.getRgtModel=function(){$scope.getRecordDetail()},$scope.initParam(),// 初始化查询列表变量
$scope.getRecordList()});